<template>
    <div class="header">
        <el-tabs v-model="activeValue" @tab-click="tabClick">
            <el-tab-pane v-for="item in panes" :label="item.label" :name="item.name" :key="item.key">
                <component :is="item.content" :activeValue="activeValue" @tab-change="tabChange" :echartParams="echartParams"></component>
            </el-tab-pane>
        </el-tabs>
    </div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import ManualProcessing from './central-supervision/manual-processing.vue';
import supervisePanorama from './central-supervision/supervise-panorama.vue';
import TransfiniteIndicator from './central-supervision/transfinite-Indicator.vue';

@Component({ name: 'CentralSupervision', components: { supervisePanorama, TransfiniteIndicator, ManualProcessing } })
export default class CentralSupervision extends Vue {
    activeValue: string = 'supervise-panorama';
    panes: any[] = [
        {
            label: '中台监督全景',
            name: 'supervise-panorama',
            content: 'supervisePanorama',
        },
        {
            label: '超限指标数据',
            name: 'transfinite-Indicator',
            content: 'TransfiniteIndicator',
        },
        {
            label: '人工处理',
            name: 'manual-processing',
            content: 'ManualProcessing',
        },
    ];

    echartParams: any = {
        isClick: true,
    };

    mounted() {
        window.addEventListener('message', this.refresh);
    }

    destroyed() {
        window.removeEventListener('message', this.refresh);
    }

    refresh(event) {
        if (event.data === 'Refresh') {
            console.log('vue-Refresh!');
            window.location.reload();
        }
    }

    // 标签页内跳转
    tabChange($event) {
        const { type, name, params } = $event;
        console.log($event, '$event-----------------change');
        this.activeValue = name[0];
        this.echartParams = { type, name, params, isClick: false };
    }

    // 点击标签
    tabClick() {
        this.echartParams.isClick = true;
    }
}
</script>
<style lang="scss" scoped>
@import '../../style/cmschina.scss';

.header {
    min-width: 1200px;
    padding-top: 4px;
    height: 100%;
}
/deep/ .el-tabs > .el-tabs__header .el-tabs__item {
    // border: 1px solid #e4e7ed;
    // border-bottom: none;
    padding: 0 14px;
    border-top-left-radius: 3px;
    border-top-right-radius: 3px;
    &:nth-child(2) {
        padding-left: 14px;
    }
    &:last-child {
        padding-right: 14px;
    }
}
/deep/ .el-tabs {
    height: 100%;
    .el-tabs__nav {
        border: none;
        // .is-active {
        //     border-color: #409eff;
        //     border-bottom: 2px solid #409eff;
        // }
    }
    .el-tabs__content {
        height: calc(100% - 35px);
        overflow: auto;
        // padding: 10px;
        .el-tab-pane {
            color: #333;
            height: 100%;
        }
    }
}

/deep/ .el-form .el-form-item__label {
    color: #333;
    padding: 0px;
}
</style>
